package com.example.adapter;


import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.example.datlichkham.Datlichhen;
import com.example.datlichkham.R;
import com.example.dto.Chuyenkhoa;

import java.util.ArrayList;

public class ChuyenKhoaAdapter extends ArrayAdapter<Chuyenkhoa> {
    LayoutInflater inflater;
    Activity activity;
    Chuyenkhoa chuyenkhoa;
    ArrayList<Chuyenkhoa> arrData;
    public ChuyenKhoaAdapter(Datlichhen activity, int textViewResourceId,
                        ArrayList<Chuyenkhoa> objects){
        super(activity, textViewResourceId, objects);
        arrData = objects;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public View getDropDownView(int position, View convertView,
                                ViewGroup parent) {
        return getCustomView(position, convertView, parent);
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        return getCustomView(position, convertView, parent);
    }

    public View getCustomView(int position, View convertView, ViewGroup parent) {
        View row = inflater.inflate(R.layout.chuyenkhoa_rows, parent, false);
        chuyenkhoa = null;
        chuyenkhoa = (Chuyenkhoa) arrData.get(position);
        TextView label=(TextView)row.findViewById(R.id.txtKhoaRow);
        label.setText(chuyenkhoa.tenKhoa);

//        ImageView icon=(ImageView)row.findViewById(R.id.icon);
        return row;
    }
}
